# _*_ coding:utf-8 _*_
# 解决相关导入的有可能bug
from __future__ import absolute_import
import os
import django
from celery import Celery
from celery.schedules import crontab
from django.conf import settings

# 猜测是配置django的环境改变，
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Persimmon.settings')
django.setup()

# 集成celery到django
app = Celery('Persimmon')
# 从配置文件中实例化app
app.config_from_object('django.conf:settings')
# 自动寻找指定的task
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.conf.result_backend = 'redis://localhost:6379/6'
# celery beat -A projb
# 轮询任务
app.conf.CELERYBEAT_SCHEDULE = {
	'calculate_movie_latest_score': {
		'task': 'movie.utils.calculate_movie_latest_score',
		'schedule': crontab(minute=u'*/1')
	}
}
